<?
include_once 'lib/facebook.php';
include_once 'includes/config.php';
include_once 'includes/dbconnect.php';
include_once 'tableObjects/TblMember.php';
include_once 'includes/function.php';
$_SESSION['pid'] = 'instruction';

echo "this is changes from desmond";
echo "this is the changes";

checkFbAuth();

if (SANDBOX_MODE == 0) {


    $isFan = $facebook->api(array(
        "method" => "pages.isFan",
        "page_id" => FACEBOOK_PAGE_ID,
        "uid" => $_SESSION['fb_id']
            ));
} else {
    $isFan = true;
}


$isFan = True;

if ($isFan === TRUE) {
    include_once 'includes/header.php';

    if (SANDBOX_MODE == 0) {
        ?>
        <script>

            try{
                if(window.top.location.toString().indexOf("http://www.facebook.com") != 0 && window.top.location.toString().indexOf("https://www.facebook.com") != 0){
                    window.top.location = "<?= FACEBOOK_PAGE_TAB_URL ?>";
                }		
            }catch(err){}			
        </script>
    <? } ?>

    <link type="text/css" href="includes/css/jquery.jscrollpane.css" rel="stylesheet" media="all" />

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
    <script type="text/javascript" src="includes/js/jquery.gchart.min.js"></script>
    <script type="text/javascript" src="includes/js/jquery.jscrollpane.min.js"></script>
    <script type="text/javascript" src="includes/js/jquery.mousewheel.js"></script>
    <script type="text/javascript" src="includes/js/jquery.imagetick.min.js"></script>

    <script language="javascript">
                                                                                                                                                                        
        function streamPublishPoll(msg,pid,hrefTitle, userPrompt)
        {
            var yes_percent = $('#question'+pid).data("yes-percent"); 
            msg=yes_percent+msg;
            FB.init({
                appId  : '<?= trim(FACEBOOK_APP_ID) ?>',
                status : true, // check login status
                cookie : true, // enable cookies to allow the server to access the session
                xfbml  : true,  // parse XFBML
                oauth  : true // enable OAuth 2.0
            });
            FB.ui(
            {
                method: 'stream.publish',
                message: msg,
                display: 'dialog',
                attachment: {
                    name: '<?= str_replace("'", "\\'", FACEBOOK_APP_NAME) ?>',
                    caption: '',
                    description: (msg),
                    href:'<?= FACEBOOK_PAGE_TAB_URL ?>',                  
                    media: [{
                            type: 'image',
                            src: 'http://www.dciapp.com/maybank/whats-your-take/fb-app/images/logo2.gif',
                            href:'<?= FACEBOOK_PAGE_TAB_URL ?>'
                        }]
                },
                action_links: [
                    {
                        text: hrefTitle, 
                        href: '<?= FACEBOOK_PAGE_TAB_URL ?>'
                    }
                ],
                user_prompt_message: userPrompt
            },
            function(response) {
                if (response && response.post_id){
                    $.ajax({
                        type: "post",
                        url: 'update_share.php',
                        data: "uid=<?= $_SESSION['fb_id'] ?>&share_msg="+msg+"&share_type=poll&share_with=wall_share&pid="+pid,
                        success: function(data) {  
                            $('#divMsg').html(data);
                        }
                    });
                                                                                                                                                                                    
                }
                                                                                                                                                                      
            }
        );
        }
                                                                                                                                                        
        function streamPublishPollCheck(pid,hrefTitle, userPrompt)
        {
            var com_percent = $('#question'+pid).data("com-percent"); 
            var mobile_percent = $('#question'+pid).data("mobile-percent"); 
            var tab_percent = $('#question'+pid).data("tab-percent"); 
                                                                                                                                                        
                                                                                                                                                        
            var msg="Devices used to access digital banking: "+com_percent+"% Computer, "+mobile_percent+"% Mobile Phone, "+tab_percent+"% Tablets.";
                                                                                                                                                        
            FB.init({
                appId  : '<?= trim(FACEBOOK_APP_ID) ?>',
                status : true, // check login status
                cookie : true, // enable cookies to allow the server to access the session
                xfbml  : true,  // parse XFBML
                oauth  : true // enable OAuth 2.0
            });
            FB.ui(
            {
                method: 'stream.publish',
                message: msg,
                display: 'dialog',
                attachment: {
                    name: '<?= str_replace("'", "\\'", FACEBOOK_APP_NAME) ?>',
                    caption: '',
                    description: (msg),
                    href:'<?= FACEBOOK_PAGE_TAB_URL ?>',                  
                    media: [{
                            type: 'image',
                            src: 'http://www.dciapp.com/maybank/whats-your-take/fb-app/images/logo2.gif',
                            href:'<?= FACEBOOK_PAGE_TAB_URL ?>'
                        }]
                },
                action_links: [
                    {
                        text: hrefTitle, 
                        href: '<?= FACEBOOK_PAGE_TAB_URL ?>'
                    }
                ],
                user_prompt_message: userPrompt
            },
            function(response) {
                if (response && response.post_id){
                    $.ajax({
                        type: "post",
                        url: 'update_share.php',
                        data: "uid=<?= $_SESSION['fb_id'] ?>&share_msg="+msg+"&share_type=poll&share_with=wall_share&pid="+pid,
                        success: function(data) {  
                            $('#divMsg').html(data);
                        }
                    });
                                                                                                                                                                                    
                }
                                                                                                                                                                      
            }
        );
        }
                                                                                                                                                                    
        function share_twitter_poll(content,pid){
            var yes_percent = $('#question'+pid).data("yes-percent"); 
            content = yes_percent +""+content;
            window.open('http://twitter.com/home?status='+content,'<?= str_replace("'", "\\'", FACEBOOK_APP_NAME) ?>','status=0,width=620,height=350,top=0,left=0');
                                                                                                                                                
            content = content.replace("'","\\'");
                                                                                                                                                
            setTimeout("updateTweeterSharePoll('"+content+"','"+pid+"')",1000);	  
        }
                                                                                                                                                        
                                                                                                                                             
        function share_twitter_poll_check(content,pid){
            var com_percent = $('#question'+pid).data("com-percent"); 
            var mobile_percent = $('#question'+pid).data("mobile-percent"); 
            var tab_percent = $('#question'+pid).data("tab-percent"); 
                                                                                                                                                        
                                                                                                                                                        
            var content="Devices used to access digital banking: "+com_percent+" percent Computer, "+mobile_percent+" percent Mobile Phone, "+tab_percent+" percent Tablets. goo.gl/VaGbx";
                                                                                                                                            
            window.open('http://twitter.com/home?status='+content,'<?= str_replace("'", "\\'", FACEBOOK_APP_NAME) ?>','status=0,width=620,height=350,top=0,left=0');
                                                                                                                                                
            content = content.replace("'","\\'");
                                                                                                                                                
            setTimeout("updateTweeterSharePoll('"+content+"','"+pid+"')",1000);	  
        }
                                                                                                                                        

        function updateTweeterSharePoll(content,pid)
        {   
                                                                                                                                    
            $.ajax({
                type: "post",
                url: "update_share.php",
                data: "uid=<?= $_SESSION['fb_id'] ?>&share_msg="+content+"&share_type=tw_poll&pid="+pid,
                success: function(data) {  
                    //$('#divMsg').html(data);
                }
            });
        }
                                                                                                                                            
                                                                                                                                            
                                                                                                                                                                    
        function roundNumber(number,decimal_points) {
            if(!decimal_points) return Math.round(number);
            if(number == 0) {
                var decimals = "";
                for(var i=0;i<decimal_points;i++) decimals += "0";
                return "0."+decimals;
            }

            var exponent = Math.pow(10,decimal_points);
            var num = Math.round((number * exponent)).toString();
            return num.slice(0,-1*decimal_points) + "." + num.slice(-1*decimal_points)
        }
                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                        
        function updateChart(question_id,result){
                                                                                                                                                                                                                                                                                                                                                        
            var split_result=result.split("&");
                                                                                                                                                                                                                                                                                                                                                        
            var split_yes=split_result[0].split("=");
            var total_yes=parseFloat(split_yes[1]);
                                                                                                                                                                                                                                                                                                                                                        
            var split_no=split_result[1].split("=");
            var total_no=parseFloat(split_no[1]);
                                                                                                                                                                                                                                                                                                                    
            var y_percent=0;
            var n_percent=0;
                                                                                                                                                                                                                                                                                                                    
            if(total_yes>0 && total_no>0)
            {                                                                                                   
                y_percent = roundNumber((total_yes/(total_yes+total_no))*100,0);
                n_percent = roundNumber((total_no/(total_yes+total_no))*100,0);
                                                                                                                                                                                                                                                                                                               
            }
            else
            {
                if(total_yes==0 && total_no>0){
                    y_percent = 0;
                    n_percent = 100;
                }else{
                    y_percent = 100;
                    n_percent = 0;
                }
            }
                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                        
            var data = [$.gchart.series('2004', [total_yes,total_no])]; 
                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                        
            data[0].color= ['#f9be20', '#000000'];
                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                         
            $('#divChart'+question_id).gchart
            ('change',
            {
                series: data,
                dataLabels: [y_percent+'%',n_percent+'%']                                                                               
            }); 
                                                                                                                                                            
                                                                                                                                                          
            $('#question'+question_id).data("yes-percent",y_percent);
                                                                                                                                                            
            $('#question'+question_id).data("no-percent",n_percent);
                                                                                                                                                            
                                                                                                                                                            
        }
                                                                                                                                                                                                        
        function updateCheckChart(question_id,result){
                                                                                                                                                                                                                                                                                                                                                        
            var split_result=result.split("&");
                                                                                                                                                                                                                                                                                                                                                        
            var split_com=split_result[0].split("=");
            var total_com=parseFloat(split_com[1]);
                                                                                                                                                                                                                                                                                                                                                        
            var split_mobile=split_result[1].split("=");
            var total_mobile=parseFloat(split_mobile[1]);
                                                                                                                                                                                                            
            var split_tab=split_result[2].split("=");
            var total_tab=parseFloat(split_tab[1]);
                                                                                                                                                                                                                                                                                                                    
            var com_percent=0;
            var mobile_percent=0;
            var tab_percent=0;
                                                                                                                                                                                                                                                                                                                    
            if(total_com>0){
                com_percent = roundNumber((total_com/(total_com+total_mobile+total_tab))*100,0);
            }
                                                                                                                                                                                                            
            if(total_mobile>0){
                mobile_percent = roundNumber((total_mobile/(total_com+total_mobile+total_tab))*100,0);
            }
                                                                                                                                                                                                            
            if(total_tab>0){
                tab_percent = roundNumber((total_tab/(total_com+total_mobile+total_tab))*100,0);
            }
                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                        
            var data = [$.gchart.series('2004', [total_com,total_mobile,total_tab])]; 
                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                        
            data[0].color= ['<?= CHART_COLOR_COM ?>', '<?= CHART_COLOR_MOBILE ?>','<?= CHART_COLOR_TAB ?>'];
                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                         
            $('#divChart'+question_id).gchart
            ('change',
            {
                series: data,
                dataLabels: [com_percent+'%',mobile_percent+'%',tab_percent+'%']                                                                               
            }); 
                                                                                                                                                        
            $('#question'+question_id).data("com-percent",com_percent);                    
            $('#question'+question_id).data("mobile-percent",mobile_percent);
            $('#question'+question_id).data("tab-percent",tab_percent);
        }
                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                    
        function getChart(question_id)
        {		
            $.ajax({
                                                                                                                                                                                                                                                                                                                                                                                                                                                        		
                type: "POST",
                url: 'chart.php',
                data: "question_id=" + question_id, 
                success: function(data) {
                    updateChart(question_id,data);                                      
                }
                                                                                                                                                                                                                                                                                                                                                                                                                                                        	
            });
                                                                                                                                                                                                                                                                                                                                                                                                                                                        				
        }
                                                                                                                                                                                                            
        function getCheckChart(question_id)
        {		
            $.ajax({
                                                                                                                                                                                                                                                                                                                                                                                                                                                        		
                type: "POST",
                url: 'check_chart.php',
                data: "question_id=" + question_id, 
                success: function(data) {
                    updateCheckChart(question_id,data);                                      
                }
                                                                                                                                                                                                                                                                                                                                                                                                                                                        	
            });
                                                                                                                                                                                                                                                                                                                                                                                                                                                        				
        }

        function submitAnswer(answer,question_id)
        {  
            if(answer=="Y"){
                $("#imgYes"+question_id).attr("src", "images/box_yes_checked.png");
                $("#imgNo"+question_id).attr("src", "images/box_no.png");
                                                                                                                                    
            }else{
                $("#imgYes"+question_id).attr("src", "images/box_yes.png");
                $("#imgNo"+question_id).attr("src", "images/box_no_checked.png");
            }
            $.ajax({
                type: "POST",
                url: 'answer_submit.php',
                data: "question_id="+question_id+"&answer="+answer, 
                success: function(data) {
                    getChart(question_id);
                    //$('#divChart'+question_id).html(data);
                }
            });	 
        }
                                                                                                                                                                                                                            
        function submitCheck(answer,question_id,check_action)
        {   
                                                                                                                                    
                                                                                                                                    
            $.ajax({
                type: "POST",
                url: 'check_submit.php',
                data: "question_id="+question_id+"&answer="+answer+"&check_action="+check_action, 
                success: function(data) {
                    getCheckChart(question_id);
                    //$('#divChart'+question_id).html(data);
                }
            });	 
        }
                                                                                                                                                                                  
        function toggleCheck(type,question_id){
                                                                                                                                                                          
            if($('#check'+type).is(':checked')) {
                submitCheck(type, question_id, 'checked');
            }else{
                submitCheck(type, question_id, 'unchecked')
                                                                                                                                                                                                                                                                                                                        
            }
        }
                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    </script>
    <div id="divComment">

    </div>

    <script type="text/javascript" src="includes/js/jquery.cycle.all.js"></script>

    <!--  initialize the slideshow when the DOM is ready -->

    <table width="800" height="500" cellpadding="0" cellspacing="0" style="border:1px solid #f5f5f5"  >

        <tr>
            <Td height="365" align="center">
                <script type="text/javascript">
                    $(function() {
                        $('#slide_banner').cycle({
                            fx: 'scrollRight' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
                        });
                    });
                </script>
                <div id="slide_banner" >                                
                    <a href=""><img src="images/text_usedigitalbanking.png" border="0" /></a>                                
                </div>
            </td>
            <td width="300" style="vertical-align: top;height:800px" rowspan="2">
                <table width="100%" >
                    <tr>
                        <td height="50" bgcolor="#fec832" style="padding-left:20px">
                            <img src="images/text_haveyoursay.png">
                        </td>
                    </tr>
                    <tr>
                        <Td width="100%" style="background-color:#cccccc">

                            <?
                            $get = mysql_query("select * from tbl_question order by order_id asc") or die(mysql_error());
                            $no = 1;


                            while ($q = mysql_fetch_assoc($get)) {
                                $question_id = $q['id'];
                                if ($q['is_multiple'] == 0) {

                                    $got_result = 0;
                                    $get_yes = mysql_query("select count(*) as result from tbl_answer where answer='Y' and question_id='$question_id'");
                                    $get_no = mysql_query("select count(*) as result from tbl_answer where answer='N' and question_id='$question_id'");

                                    $total_yes = mysql_result($get_yes, 0, "result");
                                    $total_no = mysql_result($get_no, 0, "result");
                                    $yes_percent = $no_percent = 0;


                                    if ($total_yes > 0) {
                                        $yes_percent = number_format(($total_yes / ($total_yes + $total_no)) * 100, 0);
                                    }

                                    if ($total_no > 0) {
                                        $no_percent = number_format(($total_no / ($total_yes + $total_no)) * 100, 0);
                                    }

                                    $share_copy = str_replace("[percent]", "", $q['share_copy']);
                                    $share_copy_clean = str_replace("%", " percent", $share_copy);

                                    $get_user_answer = mysql_query("select * from tbl_answer where question_id='$question_id' and fb_id='" . $_SESSION['fb_id'] . "'");



                                    if (mysql_num_rows($get_user_answer) > 0) {
                                        if (mysql_result($get_user_answer, 0, "answer") == "Y") {
                                            $img_yes = "box_yes_checked";
                                            $img_no = "box_no";
                                        } else {
                                            $img_yes = "box_yes";
                                            $img_no = "box_no_checked";
                                        }
                                    } else {
                                        $img_yes = "box_yes";
                                        $img_no = "box_no";
                                    }
                                    ?>
                                    <div id="question<?= $q['id'] ?>" data-yes-percent="<?= $yes_percent ?>" data-no-percent="<?= $no - percent ?>" ></div>
                                    <div style="padding-bottom:2px;">
                                        <table width="100%" height="100%"  cellpadding="0" cellspacing="0" style="background-color:#f1f1f1">
                                            <tr>
                                                <td style="vertical-align: top;padding-right: 10px" colspan="2" >
                                                    <a href="javascript:share_twitter_poll('<?= str_replace("'", "\\'", $share_copy_clean) ?> goo.gl/VaGbx  ','<?= $q['id'] ?>')"><img src="images/btn_twitter.png" style="float:right;margin-right: 2px" border="0"></a>                                        
                                                    <a href="javascript:streamPublishPoll('<?= str_replace("'", "\\'", $share_copy) ?>','<?= $q['id'] ?>', '<?= str_replace("'", "\\'", FACEBOOK_APP_NAME) ?>', '')" ><img src="images/btn_facebook.png" style="float:right;margin-right: 2px" border="0"></a>   
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" style="vertical-align: top;padding-top:5px" >
                                                    <table width="90%" align="center">
                                                        <Td style="vertical-align: top" width="3%"><b><?= $no ?></b></td>
                                                        <td align="left"><?= $q['question'] ?></td>

                                                    </table>

                                                </td>
                                            </tr>
                                            <tr >
                                                <td style="vertical-align: middle;padding-left: 10px" height="65">
                                                    <div id="divChart<?= $q['id'] ?>" style="width: 140px; height: 80px;">

                                                    </div>

                                                </td>
                                                <td width="120" style="float:right;display: block;padding-top:20px;padding-left: 10px">
                                                    <a href="javascript:submitAnswer('Y',<?= $q['id'] ?>)"><img src="images/<?= $img_yes ?>.png" style="float:left;margin-right: 4px" border="0" id="imgYes<?= $q['id'] ?>"><font class="poll_option"> Yes</font></a>
                                                    <br>
                                                    <a href="javascript:submitAnswer('N',<?= $q['id'] ?>)"><img src="images/<?= $img_no ?>.png"  style="float:left;margin-right:4px" border="0" id="imgNo<?= $q['id'] ?>"><font class="poll_option"> No</font></a>
                                                </td>
                                            </tr>
                                            <Tr>
                                                <Td style="height:10px">&nbsp;</td>
                                            </tr>


                                        </table>
                                    </div>

                                    <script>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                        var data = [$.gchart.series('2004', [<?= $total_yes ?>, <?= $total_no ?>])];
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                        data[0].color= ['#f9be20', '#000000'];
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                        $('#divChart<?= $q['id'] ?>').gchart({type: 'pie', series: data, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                                            dataLabels: ['<?= $yes_percent ?>%','<?= $no_percent ?>%'],
                                            backgroundColor : 'transparent',
                                            pieOrientation : 180
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                                        }); 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
                                    </script>
                                    <?
                                } else {

                                    $get_com = mysql_query("select count(*) as result from tbl_answer where answer='C' and question_id='$question_id'");
                                    $get_mobile = mysql_query("select count(*) as result from tbl_answer where answer='M' and question_id='$question_id'");
                                    $get_tab = mysql_query("select count(*) as result from tbl_answer where answer='T' and question_id='$question_id'");

                                    $total_com = mysql_result($get_com, 0, "result");
                                    $total_mobile = mysql_result($get_mobile, 0, "result");
                                    $total_tab = mysql_result($get_tab, 0, "result");

                                    $com_percent = $mobile_percent = $tab_percent = 0;

                                    if ($total_com > 0) {
                                        $com_percent = number_format(($total_com / ($total_com + $total_mobile + $total_tab)) * 100, 0);
                                    }

                                    if ($total_mobile > 0) {
                                        $mobile_percent = number_format(($total_mobile / ($total_com + $total_mobile + $total_tab)) * 100, 0);
                                    }

                                    if ($total_tab > 0) {
                                        $tab_percent = number_format(($total_tab / ($total_com + $total_mobile + $total_tab)) * 100, 0);
                                    }


                                    $com_chk = $mobile_chk = $tab_chk = "";

                                    $check_com = mysql_query("select count(*) as result from tbl_answer where question_id='" . $q['id'] . "' and fb_id='" . $_SESSION['fb_id'] . "' and answer='C'");
                                    if (mysql_result($check_com, 0, "result") > 0) {
                                        $com_chk = "checked='checked'";
                                    }

                                    $check_mobile = mysql_query("select count(*) as result from tbl_answer where question_id='" . $q['id'] . "' and fb_id='" . $_SESSION['fb_id'] . "' and answer='M'");
                                    if (mysql_result($check_mobile, 0, "result") > 0) {
                                        $mobile_chk = "checked='checked'";
                                    }

                                    $check_tab = mysql_query("select count(*) as result from tbl_answer where question_id='" . $q['id'] . "' and fb_id='" . $_SESSION['fb_id'] . "' and answer='T'");
                                    if (mysql_result($check_tab, 0, "result") > 0) {
                                        $tab_chk = "checked='checked'";
                                    }
                                    $share_copy = "Devices used to access digital banking: $com_percent% Computer, $mobile_percent% Mobile Phone, $tab_percent% Tablets. goo.gl/VaGbx ";
                                    $share_copy_clean = str_replace("%", " percent", $share_copy);
                                    ?>

                                    <div style="padding-bottom:2px">
                                        <div id="question<?= $q['id'] ?>" data-com-percent="<?= $com_percent ?>" data-mobile-percent="<?= $mobile_percent ?>" data-tab-percent="<?= $tab_percent ?>"></div> 
                                        <table width="100%" height="100%"  cellpadding="0" cellspacing="0" style="background-color:#f1f1f1">
                                            <tr>
                                                <td style="vertical-align: top;padding-right: 10px" colspan="2" >
                                                    <a href="javascript:share_twitter_poll_check('<?= $share_copy_clean ?>','<?= $q['id'] ?>')"><img src="images/btn_twitter.png" style="float:right;margin-right: 2px" border="0"></a>                                        
                                                    <a href="javascript:streamPublishPollCheck('<?= $q['id'] ?>', '<?= str_replace("'", "\\'", FACEBOOK_APP_NAME) ?>', '')" ><img src="images/btn_facebook.png" style="float:right;margin-right: 2px" border="0"></a>   

                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" style="vertical-align: top;padding-top:5px" >
                                                    <table width="90%" align="center">
                                                        <Td style="vertical-align: top"><b><?= $no ?></b></td>
                                                        <td align="left"><?= $q['question'] ?></td>
                                                    </table>
                                                </td>
                                            </tr>
                                            <tr >
                                                <td style="vertical-align: middle;padding-left: 10px" height="65">
                                                    <div id="divChart<?= $q['id'] ?>" style="width: 140px; height: 80px;"></div>

                                                </td>
                                                <td width="120" style="float:right;display: block;vertical-align: middle;padding-top:20px;padding-left: 5px">
                                                    <table>
                                                        <tr>
                                                            <td><input type="checkbox" id="checkC" <?= $com_chk ?> onchange="toggleCheck('C',<?= $q['id'] ?>)"></td>
                                                            <td><label for="checkC"><font class="poll_option">Computer</font></label></td>
                                                        </tr>
                                                        <tr>
                                                            <td><input type="checkbox" id="checkM" <?= $mobile_chk ?> onchange="toggleCheck('M',<?= $q['id'] ?>)"></td>
                                                            <td><label for="checkM"><font class="poll_option">Mobile</font></label></td>
                                                        </tr>
                                                        <tr>
                                                            <td><input type="checkbox" id="checkT" <?= $tab_chk ?> onchange="toggleCheck('T',<?= $q['id'] ?>)"></td>
                                                            <td><label for="checkT"><font class="poll_option">Tablets</font></label></td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <Tr>
                                                <Td style="height:10px">&nbsp;</td>
                                            </tr>

                                        </table>
                                    </div>

                                    <script>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

                                        $("#checkC").imageTick({ 
                                            tick_image_path: "images/checkbox_yellow_checked.png", 
                                            no_tick_image_path: "images/checkbox_yellow_no_checked.png"
                                        });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                                        $("#checkM").imageTick({ 
                                            tick_image_path: "images/checkbox_black_checked.png", 
                                            no_tick_image_path: "images/checkbox_black_no_checked.png"
                                        });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                                        $("#checkT").imageTick({ 
                                            tick_image_path: "images/checkbox_bright_checked.png", 
                                            no_tick_image_path: "images/checkbox_bright_no_checked.png"
                                        });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

            <? if ($total_com == 0 && $total_mobile == 0 && $total_tab == 0) { ?>  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
                    var data = [$.gchart.series('2004', [0,0])];

                    data[0].color= ['#f9be20','#000000'];

                    $('#divChart<?= $q['id'] ?>').gchart({type: 'pie', series: data, 

                        backgroundColor : 'transparent',
                        pieOrientation : 180                                                                                                        
                    });                                                                                                                                     

            <? } else { ?>
                    var data = [$.gchart.series('2004', [<?= $total_com ?>, <?= $total_mobile ?>,<?= $total_tab ?>])];
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                    data[0].color= ['<?= CHART_COLOR_COM ?>', '<?= CHART_COLOR_MOBILE ?>','<?= CHART_COLOR_TAB ?>'];
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                    $('#divChart<?= $q['id'] ?>').gchart({type: 'pie', series: data, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                        dataLabels: ['<?= $com_percent ?>%','<?= $mobile_percent ?>%','<?= $tab_percent ?>%'],
                        backgroundColor : 'transparent',
                        pieOrientation : 180                                                                                                        
                    });                                                                                                                                     
            <? } ?>                                                                                                                                                                                                                                                                           
                                    </script>


                                <? } $no++;
                            } ?>


                            <script type="text/javascript" id="sourcecode">
                                $(function()
                                {
                                    $('.scroll-pane').jScrollPane();
                                    $('.scroll-pane-arrows').jScrollPane(
                                    {
                                        showArrows: true,
                                        horizontalGutter: 10,
                                        autoReinitialise : true
                                    }
                                );
                                });
                            </script>
                        </td>
                </table>
            </td>

        </tr>
        <Tr>
            <td style="vertical-align: top;height:100%">
                <?
                if (eregi("chrome", $_SERVER['HTTP_USER_AGENT'])) {
                    $height = '610';
                } else {
                    $height = '608';
                }
                ?>
                <table width="100%" style="vertical-align: top;height:<?= $height ?>px; border-bottom: 1px #cccccc solid" cellpadding="0" cellspacing="0">    
                    <tr>
                        <td height="50" bgcolor="#fec832" style="padding-left:20px">
                            <img src="images/title_shareyourviews.png">
                        </td>
                    </tr>
                    <tr>

                        <Td width="100%" style="border:1px solid #f5f5f5;background-color:#f1f1f1;padding-left:20px;vertical-align: top;height:<?= $height ?>px" >
                            <style type="text/css" id="page-css">

                                .scroll-view
                                {
                                    width : 100%;

                                    height: <?= $height ?>px;                                    
                                    overflow: auto;

                                }


                            </style>
                            <div class="scroll-view">
                                <table width="100%" cellpadding="0" cellspacing="0">
                                    <?
                                    $get_question = mysql_query("select * from tbl_view_question order by created_datetime desc");

                                    $no = mysql_num_rows($get_question);
                                    while ($q = mysql_fetch_assoc($get_question)) {
                                        ?>
                                        <tr>
                                            <td style="padding-top:10px">

                                                <font class="title_question"><?= $q['question'] ?></font>

                                            </td>

                                        </tr>
                                        <tr>
                                            <Td style="text-align: right">
                                                <font style="color:#6e6e6e;font-size:12px"><?= date("M j", strtotime($q['created_datetime'])) ?> at <?= date("g:i a", strtotime($q['created_datetime'])) ?></font>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td><div class="fb-comments" data-href="<?= SOURCE_URL ?>/share_view.php?question_id=<?= $q['id'] ?>" data-num-posts="5" data-width="430"></div>
                                                <br> <br>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="background:url(images/divider_h.jpg) repeat-x center;" height="30">&nbsp;</td>
                                        </tr>

                                        <?
                                        $no--;
                                    }
                                    ?>
                                </table>
                            </div>
                            <script>
                                $(function()
                                {
                                    $('.scroll-view').jScrollPane(
                                    {
                                        autoReinitialise: true
                                                                                                                                                
                                    }
                                );
                                });
                            </script>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>


    </table>
    <?
    include_once 'includes/footer.php';
} else {


    echo "<script type='text/javascript'>top.location.href = '" . FACEBOOK_PAGE_TAB_URL . "';</script>";
}
?>